package com.woniu108.order.client;

import cn.hutool.core.bean.BeanUtil;
import com.woniu108.carService.commos.dto.*;
import com.woniu108.carService.commos.model.Result;
import com.woniu108.product.form.*;
import com.woniu108.product.param.PutStorageParam;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.jdbc.Null;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author LY
 */
@FeignClient(name = "product-server",path = "/product")
public interface ProductClient {
    /**
     * 查询用户购物车
     * @param userId 用户id
     * @return 用户购物车
     */
    @GetMapping("/productInfo/findUserCartByUserId")
    @ApiOperation("查询用户购物车")
    public Result<List<UserCartDto>> findUserCartByUserId(@RequestParam("userId") String userId);

    /**
     * 下单成功，加冻结量，减余量
     * @param form
     * @return
     */
    @GetMapping("/productInfo/successfulOrder")
    @ApiOperation("下单成功，加冻结量，减余量")
    public Result<Boolean> successfulOrder(@RequestBody SuccessfulOrderForm form);

    /**
     * 通过商品详情ID查商品信息
     * @param pInfoId 商品详情id
     * @return
     */
    @GetMapping("/productInfo/findProductInfoById")
    @ApiOperation("通过商品详情ID查商品信息")
    public Result<ProductInfoDto> findProductInfoById(@RequestParam("pInfoId")Integer pInfoId);

    /**
     * 查询所有符合条件活动
     * @param pItemId 商品编号
     * @return 商品活动集合
     */
    @GetMapping("/productActive/findAllActiveByItemId.c")
    @ApiOperation("查询所有符合条件活动")
    @ApiImplicitParam(name = "pItemId", value = "商品总览ID")
    public Result<List<ProductActiveDto>> findAllActiveByItemId(@RequestParam("pItemId")Integer pItemId);

    /**
     * 销售失败时，冻结量调回库存量
     * @param form
     * @return
     */
    @GetMapping("/productInfo/failedSale")
    @ApiOperation("销售失败时，余量增加")
    public Result<Boolean> failedSale(@RequestBody FailedSaleForm form);

    /**
     * 销售失败时，减少冻结量
     * @param form
     * @return
     */
    @GetMapping("/productInfo/submitFreezeNum")
    @ApiOperation("销售失败时，减少冻结量")
    public Result<Boolean> submitFreezeNum(@RequestBody FailedSaleForm form);

    /**
     * 订单支付成功时商品冻结量减少
     * @param form
     * @return
     */
    @GetMapping("/productInfo/successfulSale")
    @ApiOperation("订单支付成功时商品冻结量减少")
    public Result<Boolean> successfulSale(@RequestBody SuccessfulSaleForm form);

    /**
     * 销量增加
     * @param pInfoId
     * @return
     */
    @GetMapping("/productInfo/addPInfoNum")
    @ApiOperation("销量增加")
    @ApiImplicitParam(name = "pInfoId", value = "详情id")
    public Result<Boolean> addPInfoNum(@RequestParam("pInfoId") Integer pInfoId);

    /**
     * 根据serviceId查询服务信息
     * @param serviceId
     * @return
     */
    @GetMapping("/serviceInfo/findServiceInfoById.c")
    @ApiOperation("通过服务id查服务信息")
    @ApiImplicitParam(value = "serviceId", name = "服务种类编号")
    public Result<ServiceInfoDto> findServiceInfoById(@RequestParam("serviceId")Integer serviceId);

    /**
     * 查单个门店商品
     * @param spInfoId "门店商品编号"
     * @return
     */
    @GetMapping("/storeProduct/findOneStoreProductById.c")
    @ApiOperation("查单个商品")
    @ApiImplicitParam(value = "spInfoId", name = "门店商品编号")
    public Result<StoreProductDto> findOneStoreProductById(@RequestParam("spInfoId")Integer spInfoId);

    /**
     * 商品出库
     * @param form 门店商品编号 入库数量
     * @return boolean值
     */
    @GetMapping("/storeProduct/outStorage.st")
    @ApiOperation("商品出库")
    Result<Boolean> outStorage(@RequestBody OutStorageForm form);

    /**
     * 商品入库
     * @param form 门店商品编号 入库数量
     * @return boolean值
     */
    @GetMapping("/storeProduct/putStorage.st")
    @ApiOperation("商品入库")
    public Result<Boolean> putStorage(@RequestBody PutStorageForm form);

    /**
     * 商品入库
     *
     * @param form 门店商品编号 入库数量
     * @return boolean值
     */
    @GetMapping("/storeProduct/putStorage.c")
    @ApiOperation("商品入库")
    public Result<Boolean> putStorageTwo(@RequestBody PutStorageForm form) ;

    /**
     * 商品出库
     *
     * @param form 门店商品编号 入库数量
     * @return boolean值
     */
    @GetMapping("/storeProduct/outStorage.c")
    @ApiOperation("商品出库")
    public Result<Boolean> outStorageTwo(@RequestBody OutStorageForm form);
}
